<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改sys_schedul_pai')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-pai-edit" th:object="${sysSchedulPai}">
            <h4 class="form-header h4">sys_schedul_pai信息</h4>
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">排班名称：</label>
                <div class="col-sm-8">
                    <input name="name" th:field="*{name}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">创建人：</label>
                <div class="col-sm-8">
                    <input name="createName" class="form-control" th:value="${sysUser.userId}" type="hidden">
                    <span th:text="${sysUser.userName}"></span>
                </div>
            </div>
            <input name="deptId" type="hidden" id="treeId" th:field="*{deptId}"/>
            <div class="form-group">    
                <label class="col-sm-3 control-label">所属部门：</label>
                <div class="col-sm-8">
<!--                    <input name="deptId" th:field="*{deptId}" class="form-control" type="text">-->
                    <input name="deptId" onclick="selectDeptTree()" id="treeName" type="text" placeholder="默认当前部门" class="form-control">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">紧急程度：</label>
                <div class="col-sm-8">
<!--                    <input name="urgent" class="form-control" type="text">-->
                    <select name="urgent" id="urgent" class="form-control" >
                        <option th:value="*{urgent}"  th:field="*{urgent}">默认当前紧急程度</option>
                        <option value="普通">普通</option>
                        <option value="略紧急">略紧急</option>
                        <option value="紧急">紧急</option>
                    </select>
                </div>
            </div>
            <h4 class="form-header h4">排班表</h4>
            <div class="row">
                <div class="col-sm-12">
                    <div class="col-sm-12 select-table table-striped">
                        <table id="bootstrap-table" >
                            <tr class="active">
                                <td>开始时间</td>
                                <td>结束时间</td>
                                <td>值班人</td>
                            </tr>
                            <tr class="active" th:each="item,info:${relate}" th:object="${item}">
                                <td><input name="beginTime" th:value="*{beginTime}" type="text" placeholder="默认当前时间" class="form-control"></td>
                                <td><input name="endTime" th:value="*{endTime}" type="text" placeholder="默认当前时间" class="form-control"></td>
                                <td>
                                    <select name="zhiId" class="form-control">
                                        <option th:value="*{zhiId}" ><span th:text="${zhiName}"></span></option>
                                        <option th:each="item,info:${users}" th:object="${item}" th:value="*{userId}">
                                            <span th:text="*{userName}"></span>
                                        </option>
                                    </select>
                                </td>
                            </tr>

                        </table>
                    </div>
                </div>
            </div>
           <!-- <div class="row">
                <div class="col-sm-12">
                    <button type="button" class="btn btn-white btn-sm" onclick="addRow()"><i class="fa fa-plus"> 增加</i></button>
                    <button type="button" class="btn btn-white btn-sm" onclick="sub.delRow()"><i class="fa fa-minus"> 删除</i></button>
                    <div class="col-sm-12 select-table table-striped">
                        <table id="bootstrap-table"></table>
                    </div>
                </div>
            </div>-->
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/pai";
        $("#form-pai-edit").validate({
            focusCleanup: true
        });

        $("input[name='endTime'],input[name='beginTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-pai-edit').serialize());
            }
        }

        /* 用户管理-新增-选择部门树 */
        function selectDeptTree() {
            var treeId = $("#treeId").val();
            var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
            var url = ctx + "system/user/selectDeptTree/" + deptId;
            var options = {
                title: '选择部门',
                width: "380",
                url: url,
                callBack: doSubmit
            };
            console.log(deptId)
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var body = $.modal.getChildFrame(index);
            $("#treeId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            $.modal.close(index);
        }
       /* $(function() {
            var options = {
                data: [[${sysSchedulPai.sysSchedulPaiRelateList}]],
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [{
                    checkbox: true
                },
                    {
                        field: 'index',
                        align: 'center',
                        title: "序号",
                        formatter: function (value, row, index) {
                            var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                            return columnIndex + $.table.serialNumber(index);
                        }
                    },
                    {
                        field: 'beginTime',
                        align: 'center',
                        title: '开始时间',
                        formatter: function(value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='sysSchedulPaiRelateList[%s].beginTime' value='%s'>", index, value);
                            return html;
                        }
                    },

                    {
                        field: 'endTime',
                        align: 'center',
                        title: '结束时间',
                        formatter: function(value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='sysSchedulPaiRelateList[%s].endTime' value='%s'>", index, value);
                            return html;
                        }
                    },

                    {
                        field: 'zhiId',
                        align: 'center',
                        title: '值班人id',
                        formatter: function(value, row, index) {
                            var html = $.common.sprintf("<input class='form-control' type='text' name='sysSchedulPaiRelateList[%s].zhiId' value='%s'>", index, value);
                            return html;
                        }
                    },

                    {
                        title: '操作',
                        align: 'center',
                        formatter: function(value, row, index) {
                            var value = $.common.isNotEmpty(row.index) ? row.index : $.table.serialNumber(index);
                            return '<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="sub.delRowByIndex(\'' + value + '\')"><i class="fa fa-remove"></i>删除</a>';
                        }
                    }]
            };
            $.table.init(options);
        });

        function addRow() {
            var count = $("#" + table.options.id).bootstrapTable('getData').length;
            var row = {
                index: $.table.serialNumber(count),
                beginTime: "",
                endTime: "",
                zhiId: "",
            }
            sub.addRow(row);
        }*/
    </script>
</body>
</html>